package com.lesama.singleton;

// 单例模式： 复用，提高效率
// 饿汉单例模式： 使用前就创建单例对象

public class SingletonDesignDemo1 {
    public static void main(String[] args) {
        Singleton1 s1 = Singleton1.getInstance();
        Singleton1 s2 = Singleton1.getInstance();
        System.out.println(s1);
        System.out.println(s2);
    }
}

class Singleton1 {
    private Singleton1() {} // 私有构造方法

    private static final Singleton1 s = new Singleton1();

    public static Singleton1 getInstance() {
        return s;
    }
}